// TypeScript file
class startView extends egret.DisplayObjectContainer {
    public constructor() {
        super();
        this.width = 750;
        this.height = 1334;
        this.init();
    }

    private image: egret.Bitmap;

    private init() {
        this.initButton("文字1", 20, 1000, this.text_1Init);
        this.initButton("文字2", 200, 1000, this.text_2Init);
        this.initButton("文字3", 400, 1000, this.text_3Init);
        this.initButton("文字4", 20, 1100, this.text_4Init);
        this.initButton("文字5", 200, 1100, this.text_5Init);
        this.initButton("文字6", 400, 1100, this.text_6Init);
        this.initButton("文字7", 20, 1200, this.text_7Init);
        this.initButton("文字8", 200, 1200, this.text_8Init);
        this.initButton("文字9", 400, 1200, this.text_9Init);
    }

    private text_1: egret.TextField;
    private text_2: egret.TextField;
    private text_3: egret.TextField;
    private text_4: egret.TextField;
    private text_5: egret.TextField;
    private text_6: egret.TextField;
    private text_7: egret.TextField;
    private text_8: egret.TextField;
    private text_9: egret.TextField;

    private text_1Init() {
        this.text_1 = new egret.TextField();
        this.text_1.text = "文字";
        this.text_1.textColor = 0x000000;
        this.text_1.y = 0;
        this.text_1.x = 20;
        this.addChild(this.text_1);
    }

    private text_2Init() {
        this.text_2 = new egret.TextField();
        this.text_2.text = "文字背景";
        this.text_2.background = true;
        this.text_2.backgroundColor = 0x03f425;
        this.text_2.y = 100;
        this.text_2.x = 20;
        this.addChild(this.text_2);
    }

    private text_3Init() {
        this.text_3 = new egret.TextField();
        this.text_3.text = "文字字体";
        this.text_3.textColor = 0x000000;
        this.text_3.y = 200;
        this.text_3.x = 20;
        this.text_3.fontFamily = 'xjlFont';
        this.addChild(this.text_3);
    }

    private text_4Init() {
        this.text_4 = new egret.TextField();
        this.text_4.text = "文字大小";
        this.text_4.textColor = 0x000000;
        this.text_4.y = 300;
        this.text_4.x = 20;
        this.text_4.size = 50;
        this.addChild(this.text_4);
    }

    private text_5Init() {
        this.text_5 = new egret.TextField();
        this.text_5.text = "文字颜色";
        this.text_5.textColor = 0x03f425;
        this.text_5.y = 400;
        this.text_5.x = 20;
        this.addChild(this.text_5);
    }

     private text_6Init() {
        this.text_6 = new egret.TextField();
        this.text_6.text = "文字描边";
        this.text_6.textColor = 0x000000;
        this.text_6.y = 500;
        this.text_6.x = 20;
        this.text_6.stroke = 3;
        this.text_6.strokeColor = 0x0000ff;
        this.addChild(this.text_6);
    }

    private text_7Init() {
        this.text_7 = new egret.TextField();
        this.text_7.text = "文字粗体，斜体";
        this.text_7.textColor = 0x000000;
        this.text_7.y = 600;
        this.text_7.x = 20;
        this.text_7.bold = true;
        this.text_7.italic = true;
        this.addChild(this.text_7);
    }

    private text_8Init() {
        this.text_8 = new egret.TextField();
        this.text_8.text = "文字位置";
        this.text_8.textColor = 0x000000;
        this.text_8.y = 700;
        this.text_8.x = 20;
        this.text_8.textAlign = egret.HorizontalAlign.RIGHT;
        this.addChild(this.text_8);
    }


    private text_9Init() {
        this.text_9 = new egret.TextField();
        this.text_9.text = "文字输入";
        this.text_9.textColor = 0x000000;
        
        this.text_9.type = egret.TextFieldType.INPUT;
        var text_9 = new egret.Sprite()
        text_9.y = 800;
        text_9.x = 20;
        text_9.addChild(this.text_9);
        this.addChild(text_9);
    }

    //通用按钮
    private initButton(textContent, x, y, callback) {
        var text: egret.TextField = new egret.TextField();
        text.text = textContent;
        text.textColor = 0x000000;
        text.background = true;
        text.backgroundColor = 0x03f425;
        text.x = x;
        text.y = y;
        text.touchEnabled = true;
        text.addEventListener(egret.TouchEvent.TOUCH_TAP, callback, this);
        this.addChild(text);
    }

}